﻿@model QuanLyGiaoVuUI.Models.CaiDat.HocKyNamHocViewModel
@{
    ViewBag.Title = "HocKyNamHoc";
    Layout = "~/Views/Shared/_blueWhaleLayout.cshtml";
}
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
@{Html.RenderPartial("CaiDatMenuPartial");}


<div id="main" class="grid_10">
    <!--  start page-heading -->

    <div id="page-heading" class="box round first grid">
        <h2>Danh sách học kỳ</h2>
        <!-- end page-heading -->

        <div class="block">
            <div>
                @{using (Ajax.BeginForm("ThemHocKy","CaiDat",new AjaxOptions{
                      HttpMethod="POST",
                      OnSuccess="ThemHocKySuccess"
                  }))
                {
                <table>
                    <tr>
                        <td>Học kỳ</td>
                        <td><select name="TenHocKy">
                                <option value="1">1</option>
                                <option value="2">2</option>
                                <option value="3">3</option>
                            </select>
                        </td>
                        <td>Năm học</td>
                        <td>@Html.DropDownList("MaNamHoc", new SelectList(Model.danhSachNamHoc,"MaNamHoc","TenNamHoc"))</td>
                        <td><input type ="submit" value="Thêm học kỳ" id="btnThemHocKy"/></td>
                    </tr>
                </table>
                }
                }
            </div>
            <table class="data display datatable">
                <tr>
                    <th class="sorting table-header-repeat line-left minwidth-1"><a href="">Học kỳ</a></th>
                    <th class="sorting table-header-repeat line-left"><a href="">Cập nhật</a></th>
                </tr>
                @{int count = 1;}
                @foreach (var hocky in Model.danhSachHocKy)
                {
                    <tr class="gradeA @(count % 2 == 0 ? "even" : "odd")">
                        <td>@hocky.TenHocKyDayDu</td>
                        <td></td>
                    </tr>
                }
            </table>
            <!--  end product-table................................... -->
        </div>
    </div>
    <div id="page-heading" class="box round first grid">
        <h2>Danh sách năm học</h2>
        <!-- end page-heading -->

        <div class="block">
            <div>
                @{using (Ajax.BeginForm("ThemNamHoc","CaiDat",new AjaxOptions{
                      HttpMethod="POST",
                      OnSuccess="ThemHocKySuccess"
                  }))
                {
                <table>
                    <tr>
                        <td>Năm học </td>
                        <td><input id="Nam1" name="Nam1" type="text" class="yearEnter" /></td>
                        <td> - </td>
                        <td><input id="Nam2" name="Nam2" type="text" class="yearEnter" /></td>
                        <td><input type ="submit" value="Thêm năm học" id="btnThemNamHoc"/></td>
                    </tr>
                </table>
                }
                }
            </div>
            <table class="data display datatable">
                <tr>
                    <th class="table-header-repeat line-left minwidth-1"><a href="javascript:;">Năm học</a></th>
                    <th class="table-header-repeat line-left"><a href="javascript:;">Cập nhật</a></th>
                </tr>
                @{count = 1;}
                @foreach (var namhoc in Model.danhSachNamHoc)
                {
                    <tr class="gradeA @(count % 2 == 0 ? "even" : "odd")">
                        <td>@namhoc.TenNamHoc</td>
                        <td></td>
                    </tr>
                }
            </table>
            <!--  end product-table................................... -->
        </div>
    </div>
</div>

<div class="clear">&nbsp;</div>

<script>
    $(function () {
        $(".yearEnter").bind("keyup paste", function(){
            setTimeout(jQuery.proxy(function() {
                this.val(this.val().replace(/[^0-9]/g, ''));
                }, $(this)), 0);
            });
    });
       
    function ThemHocKySuccess(data) {
        if (data.success) {
            location.reload(true);
        }
        else {
            ToastManager.showStickyWarningToast(data.message);
        }
    }
</script>
